﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using FutureApp.Users;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FutureApp.Shop
{
    /// <summary>
    /// 商品SKU
    /// </summary>
    [Table("Goods")]
    public class Goods : FullAuditedEntity<Guid, User>, IPassivable, IMayHaveTenant
    {
        /// <summary>
        /// 货品ID
        /// </summary>
        [Required]
        public virtual Guid ItemId { get; set; }

        /// <summary>
        /// 货品
        /// </summary>
        [ForeignKey(nameof(ItemId))]
        public virtual GoodsItem Item { get; set; }

        /// <summary>
        /// 商品特征属性分配值
        /// </summary>
        [ForeignKey("GoodsId")]
        public virtual ICollection<GoodsAttributeDistribution> AttributeDistribution { get; set; }

        /// <summary>
        /// 商品基本属性分配值
        /// </summary>
        [ForeignKey("GoodsId")]
        public virtual ICollection<GoodsPropertyDistribution> PropertyDistribution { get; set; }

        /// <summary>
        /// 商品价格
        /// </summary>
        public virtual GoodsPrice Pricing { get; set; }

        /// <summary>
        /// 商品库存
        /// </summary>
        public virtual GoodsStock Stock { get; set; }

        /// <summary>
        /// 商品库存事务
        /// </summary>
        [ForeignKey("GoodsId")]
        public virtual ICollection<GoodsStockTransaction> StockTransactions { get; set; }

        /// <summary>
        /// 租户Id
        /// </summary>
        public virtual int? TenantId { get; set; }

        /// <summary>
        /// 激活/禁用
        /// </summary>
        public virtual bool IsActive { get; set; } = true;
    }
}
